package com.woniu.apartment.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.woniu.apartment.domain.ApartLayout;
import com.woniu.apartment.service.IApartLayoutService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公寓房型Controller
 * 
 * @author yy
 * @date 2023-04-03
 */
@RestController
@RequestMapping("/apartment/tbapartlayout")
@Api("公寓房型管理")
public class ApartLayoutController extends BaseController
{
    @Autowired
    private IApartLayoutService apartLayoutService;

    /**
     * 查询公寓房型列表
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartlayout:list')")
    @GetMapping("/list")
    @ApiOperation("公寓房型分页查询")
    public TableDataInfo list(ApartLayout apartLayout)
    {
        startPage();
        List<ApartLayout> list = apartLayoutService.selectApartLayoutList(apartLayout);
        return getDataTable(list);
    }

    /**
     * 导出公寓房型列表
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartlayout:export')")
    @Log(title = "公寓房型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("公寓房型导出")
    public void export(HttpServletResponse response, ApartLayout apartLayout)
    {
        List<ApartLayout> list = apartLayoutService.selectApartLayoutList(apartLayout);
        ExcelUtil<ApartLayout> util = new ExcelUtil<ApartLayout>(ApartLayout.class);
        util.exportExcel(response, list, "公寓房型数据");
    }

    /**
     * 获取公寓房型详细信息
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartlayout:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("根据主键查询公寓房型")
    @ApiImplicitParam(name = "ids", value = "用户ID", required = true, dataType = "Long")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(apartLayoutService.selectApartLayoutById(id));
    }

    /**
     * 新增公寓房型
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartlayout:add')")
    @Log(title = "公寓房型", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("添加公寓房型")
    public AjaxResult add(@RequestBody ApartLayout apartLayout)
    {
        return toAjax(apartLayoutService.insertApartLayout(apartLayout));
    }

    /**
     * 修改公寓房型
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartlayout:edit')")
    @Log(title = "公寓房型", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("更新公寓房型")
    public AjaxResult edit(@RequestBody ApartLayout apartLayout)
    {
        return toAjax(apartLayoutService.updateApartLayout(apartLayout));
    }

    /**
     * 删除公寓房型
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartlayout:remove')")
    @Log(title = "公寓房型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除公寓房型")
    @ApiImplicitParam(name = "ids", value = "主键数组", required = true, dataType = "Long")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(apartLayoutService.deleteApartLayoutByIds(ids));
    }
}
